import config from './config.js'
export default (url, data={}, method='GET')=>{
	return new Promise((resolve, reject)=>{
		
		wx.request({
			url:config.yunHost+url,
			data,
			method,
			header:{
				cookie: wx.getStorageSync('cookies')?wx.getStorageSync('cookies').find(item => item.indexOf('MUSIC_U') !== -1):''
			},
			success:(res)=>{
				if(data.isLogin){
					wx.setStorage({
						key:'cookies',
						data:res.cookies
					})
				}
				resolve(res.data)
				console.log('请求成功', res);
			},
			fail:(err)=>{
				reject(err)
				// console.log('请求失败', err);
			}
		})
		
	})
	
}